<template>
    <div class="add-container">
        <el-form :model="departmentInfo">
            <el-form-item label="科室名称">
                <el-input v-model="departmentInfo.name" size="mini"></el-input>
            </el-form-item>
            <el-form-item label="科室主任">
                <el-select v-model="departmentInfo.maindoctor" size="mini">
                    <el-option v-for="item in directors" :key="item.name" :label="item.name" :value="item.name">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="科室编号">
                <el-input placeholder="系统自动生成" size="mini" disabled></el-input>
            </el-form-item>
            <el-form-item label="创建时间">
                <el-input placeholder="系统自动生成" size="mini" disabled></el-input>
            </el-form-item>
            <el-form-item>
                <el-button @click="handleCOnfimCreate" type="primary" size="mini">确认创建</el-button>
                <el-button @click="$router.back()" style="background:#728cb2;color:#fff" size="mini">返回上一级</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
import { api_doctor_doctornames, api_department_add } from "@/apis/hospitalController";
export default {
    data() {
        return {
            departmentInfo: {
                name: "呼吸内科",
                maindoctor: "全部医生",
            },
            directors: ["1", "2", "3", "4", "5"]
        }
    },
    created() {
        this.getDoctorNames()
    },
    methods: {
        async getDoctorNames() {
            let res = await api_doctor_doctornames()
            this.directors = res.data.data
        },
        async handleCOnfimCreate() {
            console.log(this.departmentInfo);
            let res = await api_department_add(this.departmentInfo)
            if (res.data.code === 1) {
                this.$router.push("/hospital/management")
            }
        }
    }
}
</script>

<style lang="less" scoped>
.add-container {
    width: 100%;
    height: 100%;

    .el-form {
        .el-form-item {
            .el-input {
                width: 300px;
            }
        }
    }
}
</style>